﻿<?php
include 'test_header.php';

class test_user_captcha_process extends UnitTestCase{
	
	function setUp() {

	}
	function tearDown(){ 
		
	}

	function test_create_a_captcha_picture(){

		$path = "./tmp/" ;
		$file_name = "captcha.jpg" ;

		$captcha_process = new captcha_process( );
		$captcha_process->set_path( $path ) ;
		$captcha_process->set_file_name( $file_name );

		$this->assertTrue( $captcha_process->create_img( $file_name ) );

		$this->assertTrue( file_exists( $path.$file_name ) );
		
	}

	function test_get_phrase(){
		
		$path = "./tmp/" ;
		$file_name = "captcha.jpg" ;

		$captcha_process = new captcha_process( $path );
		$captcha_process->set_path( $path ) ;
		$captcha_process->set_file_name( $file_name );

		$this->assertTrue( $captcha_process->create_img( $file_name ) );

		$this->assertTrue( $captcha_process->get_phrase() );
	}

	function test_delete_img(){
		
		$path = "./tmp/" ;
		$file_name = "captcha.jpg" ;

		$captcha_process = new captcha_process( $path );
		$captcha_process->set_path( $path ) ;
		$captcha_process->set_file_name( $file_name );

		$this->assertTrue( $captcha_process->create_img( $file_name ) );

		$this->assertTrue( $captcha_process->delete_img() );

		$this->assertFalse( file_exists( $path.$file_name ) );
	}
	

}

$test = new test_user_captcha_process();
$test->run( new HtmlReporter() );

